import os, sys
from langchain.tools import BaseTool
from utils.format_str_to_json_tool import format_data
import requests


class get_xbaes_model_detail(BaseTool):
    name = "QuerModelDetail"
    description = "针对xbaes平台，想要获取模型详情数据时，可以使用这个工具"

    def _run(self, input_data):
        print('input_data-->', input_data, len(input_data))

        request_data = format_data().format_json_data(input_data)
        url = "http://xbasetest.dxbim.com:18898/api/open/v1/model/model"
        header = {
            "Content-Type":
            "application/json",
            "Authorization":
            "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIzMDM3ZDQ2OGM0YmI0Y2E1OGE4YTEwM2FkMzVkNjQyYyIsImV4cCI6MTczMDc4OTA0Mn0.Kw-NmiwtH1OoY624DDOWEt-otL78cpi0uEa20KBz2f4"
        }
        response = requests.request('get',
                                    url=url,
                                    headers=header,
                                    params=request_data)
        return response.text
